package office.service.hr.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import office.action.hr.form.AppointmentRegisterForm;
import office.bo.hr.impl.AppointmentRegister;
import office.domainset.BizDomainProviderSetImpl;
import office.service.hr.IAppointmentRegisterService;
import platform.common.exception.BusinessException;
import platform.common.service.impl.BaseBizServiceImpl;

public class AppointmentRegisterServiceImpl extends BaseBizServiceImpl implements IAppointmentRegisterService {

	/**
	 * 获取档案列表
	 * @return
	 * @throws BusinessException
	 */
	public List getAppointmentRegisterList() throws BusinessException{
		List listData = new ArrayList() ;
		try {
			BizDomainProviderSetImpl domainProviderSetImpl = (BizDomainProviderSetImpl) domainProviderSet;
			listData = domainProviderSetImpl.getDao().findByHqlNameAndDomian(domainProviderSetImpl.getAppointmentRegisterDP(), "findList", new HashMap());
		} catch (Exception e) {
			log.error("", e);
			throw this.handleBusinessServiceException("获取档案列表信息失败!", e);
		}
		return listData;
	}
	/**
	 * 编辑档案
	 * @throws BusinessException
	 */
	public void editAppointmentRegister(AppointmentRegisterForm objctForm)throws BusinessException{
		try {
			BizDomainProviderSetImpl domainProviderSetImpl = (BizDomainProviderSetImpl) domainProviderSet;
			AppointmentRegister bo = null;
			if(null==objctForm.getId() || ("").equals(objctForm.getId())){
				bo = (AppointmentRegister)domainProviderSetImpl.getAppointmentRegisterDP().newEmptyObj();
			}else{
				bo = (AppointmentRegister)domainProviderSetImpl.getDao().findByIdAndDomain(domainProviderSetImpl.getAppointmentRegisterDP(), objctForm.getId());
			}
			bo =(AppointmentRegister) objctForm.copyPropertiesToBO(bo);
			if(null==bo.getId() || ("").equals(bo.getId())){
				bo.generatorUUID();
			}
			//验证是否存在重复记录
			bo.store(domainProviderSet);
		} catch (Exception e) {
			log.error("", e);
			throw this.handleBusinessServiceException("编辑档案信息失败!", e);
		}
	}
	/**
	 * 根据id获取档案对象
	 * @param id
	 * @return
	 * @throws BusinessException
	 */
	public AppointmentRegisterForm getById(String id)throws BusinessException{
		AppointmentRegisterForm form = new AppointmentRegisterForm();
		try {
			BizDomainProviderSetImpl domainProviderSetImpl = (BizDomainProviderSetImpl) domainProviderSet;
			Map map = new HashMap();
			map.put("id", id);
			List list = domainProviderSetImpl.getDao().findByHqlNameAndDomian(domainProviderSetImpl.getAppointmentRegisterDP(), "findById", map);
			if(list.size()>0){
				form = (AppointmentRegisterForm)list.get(0);
			}
		} catch (Exception e) {
			log.error("", e);
			throw this.handleBusinessServiceException("根据id获取档案信息失败!", e);
		}
		return form;
	}
	/**
	 * 根据id删除档案对象
	 * @param id
	 * @throws BusinessException
	 */
	public void deleteById(String id)throws BusinessException{
		try {
			BizDomainProviderSetImpl domainProviderSetImpl = (BizDomainProviderSetImpl) domainProviderSet;
			domainProviderSetImpl.getDao().deleteById(domainProviderSetImpl.getAppointmentRegisterDP(), id);
		} catch (Exception e) {
			log.error("", e);
			throw this.handleBusinessServiceException("根据id删除档案信息失败!", e);
		}
	}
//	
//	/**
//	 * 审批车辆申请
//	 * @param id
//	 * @throws BusinessException
//	 */
//	public void checkById(String id)throws BusinessException{
//		try {
//			BizDomainProviderSetImpl domainProviderSetImpl = (BizDomainProviderSetImpl) domainProviderSet;
//			CarriageEntry bo = (CarriageEntry)domainProviderSetImpl.getDao().findByIdAndDomain(domainProviderSetImpl.getCarriageEntryDP(), id);
//			bo.setState("1");
//			bo.store(domainProviderSet);
//			CarriageManage carriage = (CarriageManage)domainProviderSetImpl.getDao().findByIdAndDomain(domainProviderSetImpl.getCarriageManageDP(), bo.getCarriageId());
//			carriage.setState("3");//设置车辆使用中
//			carriage.store(domainProviderSet);
//		} catch (Exception e) {
//			throw this.handleBusinessServiceException("根据id审核申请车辆信息失败!", e);
//		}
//		
//	}
}
